package hu.tortavar2.client.view.adminpages;

import hu.tortavar2.shared.Shop;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class _AddShopItemDialog_ extends Composite {

	private static _AddShopItemDialog_UiBinder uiBinder = GWT
			.create(_AddShopItemDialog_UiBinder.class);

	interface _AddShopItemDialog_UiBinder extends UiBinder<Widget, _AddShopItemDialog_> {
	}

	public interface AddShopPresenter {
		void onAddShopButton();
	}
	
	public _AddShopItemDialog_(AddShopPresenter presenter) {
		initWidget(uiBinder.createAndBindUi(this));
		this.presenter = presenter;
	}

	private AddShopPresenter presenter;
	Shop shop;
	@UiField Anchor addShopButton;
	@UiField DecoratedPopupPanel addShopPopup;
	@UiField TextBox shopName;
	@UiField TextBox shopAddress;
	@UiField TextBox shopPhoneNumber;
	
	@UiHandler("addShopButton")
	void onClickAddShopButton(ClickEvent e) {
		presenter.onAddShopButton();
	}
	
	
	public void show() {
		addShopPopup.show();
	}
	
	public void hide() {
		addShopPopup.hide();
	}
	// TODO Mezők ellenőrzését elvégezni!!!
	public Shop getNewShop() {
		shop = new Shop();
		shop.setShopName(shopName.getText());
		shop.setShopAddress(shopAddress.getText());
		shop.setShopPhone(shopPhoneNumber.getText());
		
		return shop;
	}
}
